create or replace procedure show_open_sessions is
   -- where can I find xml stylesheets
   url_server varchar2(1024) := 'http://localhost';
   more          boolean;
begin
   -- requires grant from user sys as:
   -- grant select on SYS.V_$SESSION to scott;
   -- grant select on SYS.V_$TRANSACTION to scott;
   --Print out a header
   htp.htmlOpen;
   htp.headOpen;
   htp.print('<TITLE>Open Sessions</TITLE>');
   htp.print('<META HTTP-EQUIV="Refresh" CONTENT="1; '||
     'URL=/dpls/sample/show_open_sessions">');
   htp.headClose;
   htp.bodyOpen;
	 m_tx.tx_links;
   htp.print('<H3><font color="red">Opened Sessions</font>');
   htp.print('</H3>');
   more := owa_util.tablePrint('v$session', 
                'BORDER=1 BGCOLOR="FFFFE0"',
                OWA_UTIL.HTML_TABLE, 'username,status,logon_time', ' where username is not null', 
                NULL, 0, NULL);
   htp.print('<H3><font color="red">Opened Transactions</font>');
   htp.print('</H3>');
   more := owa_util.tablePrint('v$transaction', 
                'BORDER=1 BGCOLOR="FFFFE0"',
                OWA_UTIL.HTML_TABLE, 'XIDUSN,XIDSLOT,STATUS,FLAG', null, 
                NULL, 0, NULL);   
   htp.bodyClose;
   htp.htmlClose;
exception
when others then
	 htp.htmlOpen;
	 htp.headOpen;
	 htp.title('Exception...');
	 htp.headClose;
	 htp.bodyOpen(cattributes=>'aLink=#008040 bgColor=#ffffff link=#0000ff text=#000000 vLink=#ff0000');
	 htp.center(htf.header(3,SQLERRM));
	 m_tx.tx_links;
   demo.link;
   htp.bodyClose;
   htp.htmlClose;
end show_open_sessions;
/
